import http from '@/utils/http'

const BASE_URL = '/card/businessCard'

export interface BusinessCardResp {
  id: string
  name: string
  gender: string
  avatar: string
  picture: string
  introduction: string
  phone: string
  email: string
  company: string
  title: string
  status: string
  description: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface BusinessCardDetailResp {
  id: string
  name: string
  gender: string
  avatar: string
  picture: string
  introduction: string
  phone: string
  email: string
  company: BusinessCardCompanyResp
  companyIntroduction: BusinessCardIntroductionResp[]
  audio:string
  audioDuration:number
  title: string
  status: string
  description: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface BusinessCardCompanyResp {
  id: number
  name: string
  longitude: string
  latitude: string
  address: string
  description: string
}
export interface BusinessCardIntroductionResp {
  id: string
  companyId: string
  title: string
  content: string
  description: string
}
export interface BusinessCardQuery {
  name: string
  gender: string
  status: string
  createUser: string
  createTime: string
  sort: Array<string>
}


export interface BusinessCardPageQuery extends BusinessCardQuery, PageQuery { }

/** @desc 查询微信名片列表 */
export function listBusinessCard(query: BusinessCardPageQuery) {
  return http.get<PageRes<BusinessCardResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询微信名片详情 */
export function getBusinessCard(id: string) {
  return http.get<BusinessCardDetailResp>(`${BASE_URL}/getCardDetail/${id}`)
}

/** @desc 新增微信名片 */
export function addBusinessCard(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改微信名片 */
export function updateBusinessCard(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除微信名片 */
export function deleteBusinessCard(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出微信名片 */
export function exportBusinessCard(query: BusinessCardQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}

/** @desc 上传头像 */
export function uploadAvatar(data: FormData) {
  return http.post(`${BASE_URL}/getAvatar`, data)
}
